
#ifndef UTILS_RAY
#define UTILS_RAY

class Ray {
public:
    Vector3f origin, direction, invDirection;
    double transportTime, minTime, maxTime;

    Ray(
        const Vector3f& orig,
        const Vector3f& dir,
        const double transTime = 0.0
    ) : origin(orig),
        direction(dir),
        transportTime(transTime)
    {
        invDirection = Vector3f(1.f / direction.x, 1.f / direction.y, 1.f / direction.z);
        minTime = 0.0;
        maxTime = std::numeric_limits<double>::max();
    }

    Vector3f operator()(const double& t) const { return origin + (float)t * direction; }

    friend std::ostream& operator<<(std::ostream& os, const Ray& r) {
        os << "Ray[origin = " << r.origin  << ", direction = " << r.direction << "]" << std::endl;
        return os;
    }
};

#endif // UTILS_RAY
